package com.lims.dao.common.impl;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;


import com.lims.dao.base.BaseDAOImpl;
import com.lims.dao.common.ITestItemDAO;
import com.lims.po.common.TestItem;

public class TestItemDAOImpl extends BaseDAOImpl<TestItem> implements ITestItemDAO {
	private static final String className=TestItemDAOImpl.class.toString();
	public List<TestItem> selectAll(){
		String hql="from TestItem order by pid";
		return super.ExecuteQuery(hql, className+"-->selectAll()");
	}
	
	public List<TestItem> selectBySampleType(int sampleTypeId){
		String hql="from TestItem where sampleType.pid=:sampleTypeId  order by pid";
		Map<String, Integer> para=new HashMap<String, Integer>();
		para.put("sampleTypeId", sampleTypeId);
		return super.ExecuteQuery(hql,para, className+"-->selectAll()");
	}
	
	public boolean saveTestItem(TestItem testItem){
		return super.saveObject(testItem, className+"-->saveTestItem(TestItem TestItem)")>0?true:false;
	}
	public boolean updateTestItem(TestItem testItem){
		return super.updateObject(testItem, className+"-->updateTestItem(TestItem TestItem)");
	}
	public boolean deleteTestItem(TestItem testItem){
		return super.deleteObject(testItem, className+"-->deleteTestItem(TestItem TestItem)");
	}
	public boolean selectTestItemByTestItemTitle(String TestItemTitle){
		String hql="from TestItem where TestItemName='"+TestItemTitle+"'";
		return super.ExecuteQuery(hql, className+"-->selectTestItemByTestItemName(String TestItemName)").size()==0?false:true;
	}
	public boolean deleteTestItemById(int pid){
		String hql="delete from TestItem where pid="+pid;
		return super.ExecuteNonQuery(hql, className+"-->deleteTestItemById(int pid)");
	}
	
	public TestItem selectTestItemById(int pid) {
		return super.selectById(pid, className+"-->selectTestItemById(int pid)");
	}
}
